package com.ax.base.common.controller;

import com.ax.base.common.service.BaseAreaService;
import com.ax.base.common.utils.AjaxRes;
import com.ax.base.common.utils.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName BaseAreaController
 * @Description TODO
 * @Author Mr.G
 * @Date 2018/9/4 18:28
 * @Version 1.0
 */
@Controller
@ResponseBody
public class BaseAreaController {

@Autowired
private BaseAreaService baseAreaService;

    /**
     * 查询省列表
     * @param ajaxRes
     * @return
     */
    @RequestMapping("getProvince")
    public AjaxRes getProvince(AjaxRes ajaxRes){
        try{
            ajaxRes.setSucceed(baseAreaService.getProvince(), Const.OPERATE_SUCCEED);
        }catch(Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return ajaxRes;

    }

    /**
     * 查询子级列表
     * @param ajaxRes
     * @param parentId 父id
     * @return
     */
    @RequestMapping("getChild")
    public AjaxRes getChild(AjaxRes ajaxRes,Long parentId){
        try{
            ajaxRes.setSucceed(baseAreaService.getChild(parentId),Const.OPERATE_SUCCEED);
        }catch(Exception e){
            ajaxRes.setFailMsg(e.getMessage());
        }
        return  ajaxRes;
    }
}
